package com.yunsom.testdemo.multiple_thread.threadpooltest1;

import com.yunsom.testdemo.dao.UrlDetail;
import java.util.List;
import java.util.Random;

/**
 * @author Xbao
 * @description
 * @date 2022/5/10 17:20
 */
public class ThreadTask implements Runnable{
  //这里实现runnable接口
  private String url;
  private List<UrlDetail> list;
  public ThreadTask(String url,List<UrlDetail> list){
    this.url=url;
    this.list=list;
  }
  //把获取的数据进行处理
  @Override
  public void run() {

//    UrlDetail detail = HttpClientUtil.send(url, UrlDetail.class);
    //模拟从url获取到了数据
    UrlDetail urlDetail = new UrlDetail();
    urlDetail.setId(new Random().nextInt(1000));

    list.add(urlDetail);
    System.out.println("处理了数据，数据id为" + list.get(list.size() - 1).getId());
  }

}